<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

use App\Models\StaffInfo;
use App\Services\SendMobileMsgServices;

class StaffSmsFix extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'staff:sms-fix';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '员工批量发短信-fix';

    protected $mobile;

    /**
     * Create a new command instance.
     *
     * @return void
     */
    function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $mobiles = [
            '15332333132',
            '17749034050', // GR
        ];

        $staffList = StaffInfo::get();

        // send sms
        $sms = new SendMobileMsgServices;

        $n = 0;
        foreach ($staffList as $staff) {
            $mobile = $staff->mobile;
            $sms->send($mobile, '各位同事：为保障春运期间旅客停车服务，2月2日4时至11日0时，暂停P4车场职工停车，请将车辆停放至西一路职工临时车场。2月3日18时至11日0时，暂停P1车场职工停车服务，请将车辆停放至P6车场，请各位同事尽量乘坐班车上下班，减少自驾，将有限资源提供给旅客使用，谢谢合作。商业管理部，二零一九年一月三十日。', 'ygc_all');
            $this->info(sprintf('STAFF_SMS: %05d. %s', ++$n, $mobile));
            sleep(1);
        }

    }

}
